// pages/profile/cpns/user-info/index.js
const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    grade: {
      type: String,
      value: "0"
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    userInfo: {
      avatarUrl: "/assets/img/profile/profile.png",
      nickName: "城旅达人"
    },
    navHeight: app.globalData.navHeight,
    userStats: {
      fans: 128,
      following: 45,
      friends: 32,
      level: 15,
      experience: "75%"
    }
  },
  
  lifetimes: {
    created: function() {
      // 模拟获取用户信息
      this.setData({
        userInfo: {
          avatarUrl: "/assets/img/profile/profile.png",
          nickName: "城旅达人"
        }
      })
    },
    attached: function() {
      this.setData({
        grade: this.data.userStats.experience
      })
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onUserInfoTap: function() {
      wx.navigateTo({
        url: '/pages/profile-detail/index'
      })
    }
  }
})
